#简单计数
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for i in l:
    print(i)
print("-----------------------------------------")


for i, e in enumerate(l):
    print(f"index:{i}, value:{e}")
print("-----------------------------------------")


i = 0
while i < 10:
    print(f"sim statement:{i}")
    i += 1

print("-----------------------------------------")



i_2 = 0
while True:
    if i_2 == 20:
        break
    print(f"sim statement:{i_2}")
    i_2 += 1

print("-----------------------------------------")


#实现斐波那契函数
x_1=0
x_2=1
x_3=0
for i in range(0, 100):
    if i <2:
      print(i)
    else:
        x_3=x_1+x_2
        print(x_3)
        x_1=x_2
        x_2=x_3


print("-----------------------------------------")
x_1=0
x_2=1
x_3=0
i = 0

while i <= 100:
    if i < 2:
        print(i)
    else:
        x_3 = x_1 + x_2
        print(x_3)
        x_1 = x_2
        x_2 = x_3
    i += 1



#自定义异常paramserror
class ParamsError (Exception):
    pass
#加
def add(a,b):
    return a+b


#减
def sub(a,b):
    return a-b

#乘
def mul(a,b):
    return a*b

#除
def divi(a,b):
    try:
        return a / b
    except ZeroDivisionError:
        raise ParamsError("分母不可以为0！")
    finally:
        print("function my_sub end")

#取整
def edivi(a,b):
    try:
        return a // b
    except ZeroDivisionError:
        raise ParamsError("取整分母不可以为0！")
    finally:
        print("function my_sub end")


#取余
def rem(a,b):
    try:
        return a % b
    except ZeroDivisionError:
        raise ParamsError("取余分母不可以为0！")
    finally:
        print("function my_sub end")

a=44

b=0

#加

print("a加b等于"+str(add(a,b)))
#减

print("a减b等于"+str(sub(a,b)))
#乘

print("a乘b等于"+str(mul(a,b)))
#除

print("a除b等于"+str(divi(a,b)))
#整除

print("a整除b等于"+str(edivi(a,b)))
#取余

print("a对b取余等于"+str(rem(a,b)))
